package com.online_vote_system.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.online_vote_system.demo.vo.Competition;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface CompetitionMapper extends BaseMapper<Competition> {

    List<Competition> getAll();
    @Update("UPDATE competition set type='0'")
    void changeZero();
    @Update("UPDATE competition set type='1' WHERE com_id=#{comId}")
    void changeOne(String comId);
    @Update("UPDATE competition set type='0' WHERE com_id=#{comId}")
    void changeOnlyZero(String comId);
    Competition getOne(String comId);
    @Update("update competition set player_id_1=#{playerId_1},player_id_2=#{playerId_2},score1=#{score1},score2=#{score2},com_name=#{comName} where com_id=#{comId}")
    void updateOne(String comId, String playerId_1, String playerId_2, String score1, String score2,String comName);
    @Insert("insert into competition (player_id_1,player_id_2,com_name) values(#{playerId_1},#{playerId_2},#{comName})")
    void insertOne(String playerId_1,String playerId_2,String comName);
    Competition getOneByType();
}
